Skip to content

Add missing roles field to getUserPermissions types#126

Merged
dshoen619 merged 1 commit into
mainfrom
per-14323-missing-roles-field-in-getuserpermissions
Jun 14, 2026
Merged

Add missing roles field to getUserPermissions types#126
dshoen619 merged 1 commit into
mainfrom
per-14323-missing-roles-field-in-getuserpermissions

Conversation

@dshoen619

@dshoen619 dshoen619 commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds roles?: string[] to TenantPermissions and ResourcePermissions interfaces in src/enforcement/interfaces.ts
  • The PDP returns a roles array in getUserPermissions responses, but the SDK types were missing this field, forcing users to use as any type assertions

Fixes PER-14323

…types

The PDP returns a roles array in getUserPermissions responses, but the
SDK types did not include it, forcing users to use type assertions.

Fixes PER-14323

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@linear

linear Bot commented Apr 1, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the SDK’s getUserPermissions response typing to match what the PDP actually returns, removing the need for consumers to rely on as any when accessing roles.

Changes:

  • Adds an optional roles?: string[] field to TenantPermissions.
  • Adds an optional roles?: string[] field to ResourcePermissions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zeevmoney zeevmoney left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the roles?: string[] addition end-to-end against the source of truth:

  • permit-backend rego emits {"permissions": [...], "roles": [...]} per entry in user_permissions.
  • PDP (/user-permissions) struct: roles: Option<Vec<String>> with serde skip_serializing_if = "Option::is_none" → field name roles, omitted when absent (never null), string array when present.
  • SDK passes the PDP response through untouched as IUserPermissions.

The type matches on field name, string[]Vec<String>, and optionality. Adding roles? to both TenantPermissions and ResourcePermissions is required for result[key].roles to type-check on the union; tsconfig has no noUncheckedIndexedAccess, so access works without as any. Well-isolated, correct.

@dshoen619 dshoen619 merged commit ee5f42e into main Jun 14, 2026
3 of 4 checks passed
@dshoen619 dshoen619 deleted the per-14323-missing-roles-field-in-getuserpermissions branch June 14, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants